#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

using namespace std;

const int N = 1e6 + 10;

int a[N];

int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)  scanf("%d", &a[i]);

    for (int i = 0; i < n - k + 1; i++)
    {
        int max = a[i];

        for (int j = i; j < i + k - 1; j++)
        {
            if (a[j] <= a[j + 1])
                max = a[j + 1];
        }

        cout << max << ' ';
    }
    return 0;
}
